import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 牛客网.简单题.密码检查
 */
public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        in.nextLine();
        while((n--) != 0){
            boolean[] flag = new boolean[3];
            String s = in.nextLine();
            int count = 0;
            if(s.length() < 8){
                System.out.println("NO");
                continue;
            }
            if(s.charAt(0) >= '0' && s.charAt(0) <= '9'){
                System.out.println("NO");
                continue;
            }
            for(int i = 0; i < s.length(); i++){
                if(s.charAt(i) >= 'A' && s.charAt(i) <= 'Z'){
                    flag[0] = true;
                }
                if(s.charAt(i) >= 'a' && s.charAt(i) <= 'z'){
                    flag[1] = true;
                }
                if(s.charAt(i) >= '0' && s.charAt(i) <= '9'){
                    flag[2] = true;
                }
            }
            for(int j = 0; j < 3; j++){
                if(flag[j] == true){
                    count++;
                }
            }
            if(count > 1){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }
    }
}
